<template>
<div>
    <van-nav-bar
  title="登录页面"
  left-arrow
  @click-left="$router.go(-1)"
/>
<van-form @submit="onSubmit">
  <van-field
    v-model="username"
    name="用户名"
    label="用户名"
    placeholder="用户名"
    :rules="[{ required: true, message: '请填写用户名' }]"
  />
  <van-field
    v-model="password"
    type="password"
    name="密码"
    label="密码"
    placeholder="密码"
    :rules="[{ required: true, message: '请填写密码' }]"
  />
  <div style="margin: 16px;">
    <van-button round block type="info" native-type="submit" @click="dologin">立即登录</van-button>
  </div>
</van-form>
</div>
</template>

<script>
export default {
 // 组件名称
 name: 'demo',
 // 组件参数 接收来自父组件的数据
 props: [],
 // 局部注册的组件
 components: {},
 // 组件状态值
 data () {
 return {
    username:"",
    password:""
}
 },
 // 计算属性
 computed: {},
 // 侦听器
 watch: {},
 // 组件方法
 methods: {
    dologin(){
        if(this.username=="" || this.password==""){
            return false;
        }
        let token = "wqh";
        this.$store.commit("dologin",{
            username:this.username,
            token:token
        })
        this.$toast.success("登录成功");
        this.$router.go(-1);
    },

},
 // 以下是生命周期钩子 注：没用到的钩子请自行删除
 created () {
 },
 mounted () {
 },
 updated () {
 },
}
</script> 

<style scoped>

</style>
